import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
/**
 * Xss 漏洞检查
 */
export var XssValidator = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(rule, value) {
    var regexp;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          regexp = /.*<(script|a|img|link|style|iframe|frame|onerror|body|document|acx|ScRiPt|svg|IMG|SCRIPT|BODY|BGSOUND|br|LAYER|LINK|META|IFRAME|FRAMESET|DIV|STYLE|BASE|XML|A|BR|TABLE|TD|M|marquee|details|embed|sCrIpT|mArQuEe|MaRqUeE|base|textarea|div|form|input).*/gi;
          if (!(typeof value === 'string' && value !== null && value !== void 0 && value.match(regexp))) {
            _context.next = 5;
            break;
          }
          throw new Error('内容有可能对网站造成安全威胁，请检查');
        case 5:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function XssValidator(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}();